package com.gy.education.mine;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gy.education.BaseFragment;
import com.gy.education.R;
import com.gy.education.home.adapter.CertificateAdapter;
import com.gy.education.utils.AnimUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 高岳 on 2016/7/12.
 * Describe:
 */
public class MineFragment extends BaseFragment {

    private ImageView imgHead,imgIdentifyTrue,imgIdentifyStudent,imgIdentifyClass,imgTest;
    private TextView tvName,tvSchool,tvPhone,tvIntegral;
    private GridView gridView;
    private LinearLayout llInfo;
    private CertificateAdapter adapter;
    private List<String> certificateList;
    private Intent intent;

    @Override
    protected View setView(LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.fragment_mine,null);
        _baseBack.setVisibility(View.GONE);
        _imgRight.setImageResource(R.mipmap.ic_center_set);
        setTitleMsg("个人中心");
        return view;
    }

    @Override
    protected void initView() {
        imgHead = (ImageView) _rootView.findViewById(R.id.fg_mine_img_head);
        imgIdentifyTrue = (ImageView) _rootView.findViewById(R.id.fg_mine_img_true);
        imgIdentifyStudent = (ImageView) _rootView.findViewById(R.id.fg_mine_img_student);
        imgIdentifyClass = (ImageView) _rootView.findViewById(R.id.fg_mine_img_class);
        imgTest = (ImageView) _rootView.findViewById(R.id.fg_mine_img_test);
        tvName = (TextView) _rootView.findViewById(R.id.fg_mine_tv_name);
        tvSchool = (TextView) _rootView.findViewById(R.id.fg_mine_tv_school);
        tvPhone = (TextView) _rootView.findViewById(R.id.fg_mine_tv_phone);
        tvIntegral = (TextView) _rootView.findViewById(R.id.fg_mine_tv_integral);
        gridView = (GridView) _rootView.findViewById(R.id.fg_mine_gridview);
        llInfo = (LinearLayout) _rootView.findViewById(R.id.fg_mine_ll_info);
    }

    @Override
    protected void initData() {
        certificateList = new ArrayList<>();
        adapter = new CertificateAdapter(mContext,certificateList);
    }

    @Override
    protected void setListener() {
        super.setListener();
        imgIdentifyTrue.setOnClickListener(this);
        imgIdentifyStudent.setOnClickListener(this);
        imgIdentifyClass.setOnClickListener(this);
        imgTest.setOnClickListener(this);
        llInfo.setOnClickListener(this);
    }

    @Override
    protected void fillData() {
        super.fillData();
        gridView.setAdapter(adapter);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()){
            case R.id._right:
                intent = new Intent(mContext,SettingActivity.class);
                startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
                break;
            case R.id.fg_mine_img_true://实名认证
                intent = new Intent(mContext,IdentifyActivity.class);
                startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
                break;
            case R.id.fg_mine_img_student://学生认证
                intent = new Intent(mContext,IdentifyTrueSuccessActivity.class);
                startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
                break;
            case R.id.fg_mine_img_class:
                intent = new Intent(mContext,IdentifyStudentActivity.class);
                intent.putExtra("position",101);
                startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
                break;
            case R.id.fg_mine_img_test:
                intent = new Intent(mContext,IdentifyStudentSuccessActivity.class);
                startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
                break;
            case R.id.fg_mine_ll_info://个人信息
                intent = new Intent(mContext,MyInfoActivity.class);
                startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
                break;
        }
    }
}
